package Project;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/**
 * This is a class contains the graphics of saveFile list
 * of load-game title screen. 
 * 
 * @author	Brian Wetherbee
 * 			Ryan McNamara
 * 			Zeng Yang
 *
 */
public class TitleScreenLoadGame extends Menu {
	
    private javax.swing.JLabel currentGame;


	public TitleScreenLoadGame(){
		super(SaveFile.getNumberOfFiles());
		initComponents();
		
    }

	 public void paint(Graphics g){
		 	super.paint(g);
	    	g.setColor(Color.BLACK);
	    	g.fillRect(0, 0, Constants.width, Constants.height);
	    	g.setColor(Color.WHITE);
	    	g.setFont(new java.awt.Font("DialogInput",1,50));
	    	
	    	String toDraw = "save" + (getOption() + 1);
	    	
	    	FontMetrics f = g.getFontMetrics(new java.awt.Font("DialogInput",1,50));
	    	int stringX = (int) Main.actualToInternalX(f.stringWidth(toDraw));
	    	int stringY = (int)Main.actualToInternalX(f.getHeight());
	    	int x = Constants.width / 2 - (stringX/2);
	    	int y = (int) (Constants.height / 2 + (stringY)/2);
	    	g.drawString(toDraw,x, y);
	    	
	    	
	    }
	    
	    
	    @SuppressWarnings("unchecked")
	    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
	    private void initComponents() {
	        addKeyListener(this);
	        addMouseListener(this);
	        repaint();
	    }// </editor-fold>          

    @Override
    public void increaseHighlight() {
    	// TODO Auto-generated method stub
    	super.increaseHighlight();
    	repaint();
    }
    @Override
    public void decreaseHighlight() {
    	// TODO Auto-generated method stub
    	super.decreaseHighlight();
    	repaint();

    }
    
	@Override
	public void select() {
		SaveFile.LoadFile(getOption(), true);
		Main.setCurrentUI(Constants.GalaxyMapNum);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(KeyEvent e) {
		 if(e.getKeyCode() == Constants.controlDown)
	        {
			 decreaseHighlight();
	        }
	        
	        if(e.getKeyCode() == Constants.controlUp)
	        {
	            increaseHighlight();
	            
	        }
	        
	        if(e.getKeyCode() == Constants.controlConfirm)
	        {
	            select();
	        }
	        if(e.getKeyCode() == Constants.controlQuit){
	        	Main.setCurrentUI(Constants.TitleScreenNum);
	        }
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

}
